package com.example.springboot1.service.iml;


import com.example.springboot1.dao.UserMapper;
import com.example.springboot1.entity.User;
import com.example.springboot1.service.Loginservice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class Loginserviceiml implements Loginservice {
    @Autowired
    UserMapper userMapper;
    @Override
    public boolean login(String username, String password) {
        User user=userMapper.getuserByName(username);
        if(user==null){
            log.info("账号密码不存在");
            return false;
        }else if(user.getPassword().equals(password)){
            log.info("登陆成功");
            return true;
        }
        else {
            log.info("登陆失败");
            return false;
        }
    }

    @Override
    public boolean isusernameexists(User user) {
        if(userMapper.selectByUsername(user.getUsername())!=0){
            return true;
        }
        else {
            return false;
        }
    }
}
